<template>
  <div class="tab-box">
    <div class="h5">
      <div class="navbar-title">
        {{ componentData[`title${capitalizeLang}`] }}
      </div>
      <div class="navbar-subtitle">
        <span>{{ $t('common.released') }}: {{ createTime }}</span>
        <span>{{ $t('common.source') }}: {{ componentData[`source${capitalizeLang}`] }}</span>
      </div>
      <div class="navbar-box">
        <div v-for="(item, index) in componentData.list" :key="index" class="navbar-in">
          <p
            v-if="item.type === 'text'"
            :class="{
              indent: item.indent === '1',
              'align-ct': item.align === '2',
              'align-fr': item.align === '3',
            }"
            class="navbar-content"
          >
            {{ item.content }}
          </p>
          <template v-if="item.type === 'image'">
            <div v-for="(c, cindex) in item.content" :key="cindex" class="navbar-image">
              <img :src="c.response" alt="" />
              <span v-if="item.url">
                {{
                  capitalizeLang === 'Zh'
                    ? '点击图片(查看原文)'
                    : 'Click on the image (view original article)'
                }}
              </span>
            </div>
          </template>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { mapGetters } from 'vuex'
export default {
  props: {
    componentData: {
      type: Object,
      default: () => ({}),
    },
  },
  data() {
    return {
      currentNavbar: 0,
    }
  },
  computed: {
    ...mapGetters(['capitalizeLang']),
    createTime() {
      return this.$route.query?.createTime
    },
  },
}
</script>

<style lang="less" scoped>
@import '~assets/var';

.tab-box {
  background: #fff;

  .h5 {
    padding: 0;
    color: #fff;
    background: #f6f7f9;
    margin: 0 24px;

    .navbar-title {
      font-size: 36px;
      padding: 32px 40px 20px 40px;
      margin-top: 30px;
      border-bottom: 1px solid #ddd;
      font-weight: bold;
      color: #333;
      text-align: center;
    }

    .navbar-subtitle {
      font-size: 22px;
      margin: 16px 0 20px 0;
      color: #888;
      text-align: center;

      span {
        margin: 0 40px;
      }
    }

    .navbar-box {
      margin-top: 0;
      padding: 24px;
      color: #666;

      .navbar-in {
        font-size: 24px;
        font-weight: 500;
        line-height: 30px;
      }

      .navbar-image {
        img {
          width: 100%;
          margin-bottom: 30px;
        }

        span {
          color: #999;
          display: block;
          text-align: center;
          margin-top: -30px;
          margin-bottom: 30px;
        }
      }

      .navbar-content {
        margin-bottom: 30px;
        color: #666;

        &.indent {
          text-indent: 2em;
        }

        &.align-ct {
          text-align: center;
        }

        &.align-fr {
          text-align: right;
        }
      }
    }
  }
}
</style>
